﻿using System.Collections.Generic;
using System.Linq;
using IFDB.Models.Contexts;
using IFDB.Models.Tables;

namespace IFDB.ViewModels.PartialViewModels
{
    public class SearchViewModel
    {
        public IEnumerable<TeamName> SearchTeams(string term)
        {
            using (IFDBContext db = new IFDBContext())
                return db.TeamNames.Where(t => t.Name.Contains(term)).Take(10).ToList();
        }

        public IEnumerable<Person> SearchPersons(string term)
        {
            using (IFDBContext db = new IFDBContext())
                return db.Persons.Where(p => p.Surname.Contains(term) || p .Forenames.Contains(term)).Take(10).ToList();
        }
    }
}
